import javax.swing.JLabel;
class SelectionSort<T extends Comparable<T>> extends SortAlgorithm<T> { 
    SelectionSort(JLabel listLabel, JLabel timeLabel, JLabel averageTimeLabel, JLabel statusLabel) { 
        super(listLabel, timeLabel, averageTimeLabel, statusLabel); 
    }
    //Outer loop: i++ from 0 to N - 1
    //Loop: j++ from i+1 to N, "select" smallest a[j]
    //swap(a[i], a[j])  (i.e. put smalles in a[i])
    @Override
    protected void sort() {
        int N = m_list.size();
        int i, j, smallestIndex;
        for (i = 0; i < N - 1; i++) {
            smallestIndex = i;
            for (j = i+1; j < N; j++) {
                if (less(j, smallestIndex)) smallestIndex = j;
            }
            swapElements(i, smallestIndex);
        }
    }
}